package com.bjb.vr.operation.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bjb.vr.common.ao.OptCusResBundleAo;
import com.bjb.vr.common.ao.ResContentAo;
import com.bjb.vr.common.dto.ResBundle;
import com.bjb.vr.common.result.BaseResult;
import com.bjb.vr.common.result.CommonResult;
import com.bjb.vr.common.service.OptCusResBundleService;
import com.bjb.vr.common.service.ResContentService;
import com.bjb.vr.common.vo.OptCusResBundleContentVo;
import com.bjb.vr.common.vo.ResPlatformVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @version 1.0.0
 * @description:客户配置管理-资源包管理
 * @author: caihaibo
 * @createDate: 2022/9/8
 */
@RestController
@RequestMapping("/api/operation/v1")
public class CusResBundleController {

	@Autowired
	private OptCusResBundleService optCusResBundleService;

	@Autowired
	ResContentService contentService;

	/**
	 * 客户配置管理-资源包管理-查询资源包分页列表
	 * @param optCusResBundleAo
	 * @return
	 */
	@PostMapping("/queryCusResBundleList")
	public BaseResult<IPage<ResBundle>> queryCusResBundleList(@RequestBody OptCusResBundleAo optCusResBundleAo) {
		return CommonResult.Ok().setResult(optCusResBundleService.queryCusResBundleList(optCusResBundleAo));
	}


	/**
	 * 客户配置管理-资源包管理-查看包内资源
	 * @param optCusResBundleAo
	 * @return
	 */
	@PostMapping("/queryCusResBundleDetailList")
	public BaseResult<List<OptCusResBundleContentVo>> queryCusResBundleDetailList(@RequestBody OptCusResBundleAo optCusResBundleAo){
		return CommonResult.Ok().setResult(optCusResBundleService.queryCusResBundleDetailList(optCusResBundleAo));
	}

	/**
	 * 客户配置管理-资源包管理-查看资源详情
	 * @param resContentAo
	 * @return
	 * @throws Exception
	 */
	@PostMapping("/queryCusResBundleResInfo")
	public BaseResult<ResPlatformVo> queryCusResBundleResInfo(@RequestBody ResContentAo resContentAo) throws Exception {
		Assert.notNull(resContentAo.getId(), "资源id不能为空");
		Assert.notNull(resContentAo.getTenantId(), "租户id不能为空");
		ResPlatformVo resPlatformVo = contentService.queryCusResBundleResPlat(resContentAo);
		return CommonResult.Ok().setResult(resPlatformVo);
	}
}
